<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>帮帮网-用户登录</title>

<style type="text/css">
.txt
{
	padding:10px;
}
</style>
<link href="../CSS/formStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../JS/prototype.js"></script>
<script type="text/javascript" src="../JS/httpRequest.js"></script>
<script type="text/javascript" src="../JS/cookie.js"></script>

<script type="text/javascript">
function Login()
{
	
	var warn=document.getElementById('warn');
	var username=document.getElementById('txtUsername').value;
	if(username==null ||username=="")
	{
		warn.innerHTML="您还没有填写账号";
		return;
	}
	var pwd=document.getElementById('txtPwd').value;
	if(pwd==null ||pwd=="")
	{
		warn.innerHTML="您还没有填写密码";
		return;
	}
	
	var url="user.php?action=GetUser";
	var para="username="+username;
	para+="&password="+pwd;
	var response=SendPostRequest(url,para);
	alert(response);
	if(response=="false")
	{
		warn.innerHTML="登录失败！用户名或密码错误！";
		return;
	}
	else
	{
	//TODO
	//记录用户登录时间 并比对上次的登陆时间 刷新活跃度
		alert(response);
		document.cookie="username"+"="+username+";path=/;";
		document.cookie="userID"+"="+response+";path=/;";
		if (username!=null || username!="")
		{
			alert('Welcome again '+username+'! 每天都登陆的话 会增加您的活跃度 但是一天之中反复登陆是没有用的哦')
		}
		else
		{
			alert('???');
		}

		//window.location.href="../index.htm";
		window.location.href="../myspace.htm";

	}
		
	
	
}

</script>
</head>

<body>
<div style="width:250px; padding:20px; text-align:center">
<div id="warn" class="warning"></div>
<div  class="txt">账号：<input type="text" id="txtUsername" /></div>
<div class="txt">密码：<input type="text" id="txtPwd" /></div>
<input type="button"  value="登录" onclick="Login()" title="如果坚持每天登录的话 会按照kakassi法则给予活跃度奖励"/><br /><br />
<a href="register.htm"> 立即注册 </a>

</div>
</body>
</html>
